<template>
  <div>
    <div id="handle">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="">
          <el-input
            v-model="formInline.user"
            placeholder="请输入搜索新闻标题"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-plus"
            @click="dialogVisible = true"
            >添加</el-button
          >
          <el-dialog title="添加新闻" :visible.sync="dialogVisible" width="30%">
            <el-form
              :model="ruleForm"
              :rules="rules"
              ref="ruleForm"
              label-width="100px"
              class="demo-ruleForm"
            >
              <el-form-item label="新闻标题" prop="name">
                <el-input v-model="ruleForm.name"></el-input>
              </el-form-item>
              
              <el-form-item label="新闻作者" prop="name" style="margin-top:20px">
                <el-input v-model="ruleForm.name"></el-input>
              </el-form-item>
              <el-form-item label="活动时间" required style="margin-top:20px">
                <el-col :span="21">
                  <el-form-item prop="date1">
                    <el-date-picker
                      type="date"
                      placeholder="选择日期"
                      v-model="ruleForm.date1"
                      style="width: 100%"
                    ></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-form-item>
              <el-form-item label="是否上架" prop="delivery">
                <el-switch v-model="ruleForm.delivery"></el-switch>
              </el-form-item>
              <el-form-item label="新闻内容" prop="desc">
                <el-input type="textarea" v-model="ruleForm.desc"></el-input>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="dialogVisible = false"
                >确 定</el-button
              >
            </span>
          </el-dialog>
        </el-form-item>
      </el-form>
    </div>
    <div id="content1">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="title" label="标题"  align="center"> </el-table-column>
        <el-table-column prop="author" label="作者" align="center"> </el-table-column>
        <el-table-column prop="time" label="时间" align="center"> </el-table-column>
        <el-table-column prop="edit" label="操作" align="center">
          <el-button class="el-icon-edit" type="primary">编辑</el-button>
          <el-button class="el-icon-delete" type="danger">删除</el-button>
        </el-table-column>
      </el-table>
    </div>
    <div id="footer">
      <el-pagination background layout="prev, pager, next" :total="1000">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
      dialogVisible: false,
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" },
        ],
        date1: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
      },
      tableData: [
        {
          time: "2016-05-02",
          author: "央视新闻客户端",
          title: "习近平海南行 久久不见久久见",
        },
        {
          time: "2016-05-02",
          author: "新华社微博",
          title: "习近平：只有攥紧中国种子，才能端稳中国饭碗",
        },
        {
          time: "2016-05-02",
          author: "央视新闻",
          title: "上海划定首批“三区”名单，封控区实施“7+7”管理",
        },
      ],
    };
  },
  methods: {
    alterbox() {
      console.log(123);
    },
  },
};
</script>

<style scoped lang="scss">
#handle {
  margin-top: 20px;
  margin-left: 50px;
}
#content1 {
  margin-left: 50px;
  margin-top: 50px;
  width: 80vw;
}
#footer{
  margin-top: 20px;
  text-align: right;
}
</style>